<script type="text/javascript">
    $(document).ready(function () {
        $('form').submit(function (e) {
            e.preventDefault();
            var data = 'login=' + $(this).find('.login_nick').val() + '&password=' + $(this).find('.password').val();

            $.ajax({
                url:'<?php echo base_url() . "login/loginfb/"?>',
                type:'POST',
                data:data,
                success:function (r) {
                    var obj = eval("(" + r + ")");
                    if (obj == "LoginOk") {
                        $('.login').load('<?php echo base_url();?>login/loadMenu');
                        $('.reg_div h1').html('Prihlásenie bolo úspešné!');
                        $('.forma').empty();
                        $(function () {
                            setTimeout(function () {
                                $('#facebox').hide();
                                $('.warn_comments').hide();
                                $('.warn_thumbs').hide();
                                $('.facebox_overlayBG').hide();
                                $('.facebox_overlay').hide();
                            }, 2000);
                        });
                    }
                    else if (obj == "Error") {
                        if ($('.reg_errorfb').html != "") {
                            $('.reg_errorfb').fadeOut(500);
                            $('.reg_errorfb').fadeIn(500);
                        }
                        $('.reg_errorfb').html('<span style="font-size:10px; color:#ff0000;">' + "Nesprávne meno/heslo!" + '</span>');
                    }

                }
            });
            // return false;
        });

    });
</script>

<div class="reg_div">
    <h1 style='text-align: center;'>Prihlásenie</h1>
	<span class="forma">
	<div class='reg_errorfb' style='text-align: center;'></div>
	<ul style="list-style: none;text-align: center;padding:3px;">
        <?php
        echo form_open('login/loginfb');
        echo "<li>";
        echo form_input(array('type' => 'text', 'size' => '19', 'class' => 'login_nick', 'name' => 'login_', 'placeholder' => 'Prihlasovacie meno'));
        echo "</li>";
        echo "<li>";
        echo form_input(array('type' => 'password', 'size' => '19', 'class' => 'password', 'name' => 'password', 'placeholder' => 'Heslo'));
        echo "</li>";
        echo "<li>";
        echo form_submit(array('type' => 'submit', 'value' => 'Prihlásiť!', 'class' => 'reg_button'));
        echo "</li>";
        echo form_close();
        ?>
    </ul>
</span>

</div>